package com.swust.listview;

import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "--->";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }

    protected void init() {
        ListView listView = findViewById(R.id.listview);
        List<Integer> sources = Arrays.asList(1, 2, 3, 4, 5, 6);
        MineListViewAdapter adapter = new MineListViewAdapter(this, sources);
        listView.setAdapter(adapter);

        listView.setOnItemClickListener((parent, view, position, id) -> {
            adapter.setPrePosition(view, position);
        });
    }
}